'''
Created on Nov 19, 2010

@author: namikata
'''

from pyglet import image

FONTTYPE = 0
TEXTTYPE = 1
IMAGETYPE = 2
SOUNDTYPE = 3
MUSICTYPE = 4

class Resources(object):
    '''
    classdocs
    '''

    dic = {}
    
    def __getattr__(self, key):
        return self.dic.get(key)
    
    def __init__(self,resources_file):
        '''
        Constructor
        '''
                
        reslist = open(resources_file,"r").readlines()
        
        for res in reslist:           
            res = res.replace("\n","").split(":")
            res[0] = int(res[0])
            
            if res[0] == FONTTYPE:
                pass
                #load font
            elif res[0] == IMAGETYPE:
                #load image
                self.dic[res[1]] = image.load(res[2])
                self.dic[res[1]].anchor_x = self.dic[res[1]].width // 2 
                self.dic[res[1]].anchor_y = self.dic[res[1]].height // 2 
            elif res[0] == SOUNDTYPE:
                pass
                #load sound
            elif res[0] == MUSICTYPE:
                pass
                #load music
            elif res[0] == TEXTTYPE:
                #load text
                self.dic[res[1]] = res[2]